<extend name="Public:base" />

<block name="content">

    <form action="{:U('InvoiceManage/index')}" method="post">
        <div class="table-responsive">
            <table class="table table-striped table-bordered table-hover search-form">
                <thead>
                <tr>
                    <th>
                        <input class="marginL10" name="number" type="text" value="{:I('order_id')}"  placeholder="发票申请编号" value="{:I('order_id')}" />
                        <input class="marginL10" name="name" type="text" value="{:I('order_id')}"  placeholder="用户姓名" value="{:I('order_id')}" />
                        <input class="marginL10" name="phone" type="text" value="{:I('order_id')}"  placeholder="用户电话" value="{:I('order_id')}" />
                        <input class="btn btn-primary radius5 btn-sm" type="submit" value="查询"/>
                        <!--  <a class="btn btn-primary" href="javascript:;" id="search" url="{:U('Member/index')}">搜索</a>-->
                    </th>
                </tr>
                </thead>
            </table>
        </div>
    </form>
    <div class="table-responsive">
        <table class="table table-striped table-bordered table-hover" id="mytable">

            <thead>
            <tr>
                <th>发票申请编号</th>
                <th>发票抬头</th>
                <th>发票金额（元）</th>
                <th>税率费（元）</th>
                <th>快递费支付方式</th>
                <th>邮寄信息</th>
                <th>申请时间</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <volist name="list" id="ba" key="k">
                <tr>
                    <td><a href="{:U('Invoice/detail&id=').$ba['number']}">{$ba['number']}</a></td>
                    <td>{$ba['name']}</td>
                    <td>{$ba['money']}</td>
                    <td>{$ba['tax']}</td>
                    <td>{$ba['method']}</td>
                    <td>{$ba['contacts_name']}{$ba['contacts_phone']}{$ba['address']}{$ba['email']}</td>
                    <td>{$ba['add_time']|date="Y-m-d H:i:s",###}</td>
                    <td>{$ba['status']==1?'待邮寄':'已邮寄'}</td>
                    <td>
                        <php>if($ba['status']==2)
                        echo '快递：'.$ba['express'].'<br>快递单号：'.$ba['express_number']
                    </php>
                        <php>
                            if($ba['status']==1)
                            echo "<input  class='btn btn-info radius5 btn-xs' type='button' value='邮寄' onclick='tip(".$ba['id'].")'>"
                        </php>
                    </td>
                </tr>
            </volist>
            <tr>
                <td colspan="20" class="page">{$page}</td>
            </tr>
            </tbody>
        </table>
    </div>
</block>
<block name="css">
</block>
<block name="javascript">
    <script>
        function op(id){
            $.ajax({
                type:'post',
                url:"{:U('InvoiceManage/op')}",
                data:{
                    id:id
                },
                success:function(){
                    window.location="{:U('InvoiceManage/invoice')}"

                }
            })
        }
    </script>

    <script>

        function tip(id){
            var html = "<div style='padding:10px;'>快递公司：<input type='text' id='number1' name='express' /></div>";
            html+="<div style='padding: 10px'>快递单号：<input  name='number'  type='text'/></div>"
            var submit = function (v, h, f) {
                /*if (f.yourname == '') {
                 $.jbox.tip("请输入您的姓名。", 'error', { focusId: "yourname" }); // 关闭设置 yourname 为焦点
                 return false;
                 }*/

                $.ajax({
                    url:"{:U('InvoiceManage/addMessage')}",
                    type:'post',
                    data:{
                        express: f.express,
                        number: f.number,
                        id:id
                    },
                    success:function(data){
                        console.log(data)
                        if(data==2){
                            $.jbox.info('快递公司不能为空')
                        }else if(data==3){
                            $.jbox.info('快递编号不能为空')
                        }else{
                            window.setTimeout(function () { $.jbox.info('添加成功');location.reload()}, 1000);
                        }
                    }

                })
              //  console.log(f.number)
               // console.log(f.express)
                //console.log(id)
                // $.jbox.tip("你叫：" + f.yourname);
                //$.jBox.tip("你叫：" + h.find("#yourname").val());
                //$.jBox.tip("你叫：" + h.find(":input[name='yourname']").val());

                return true;
            };

            $.jbox(html, { title: "请输入记录", submit: submit });
        }
    </script>
</block>